package three.w;

import java.util.Scanner;

interface List {
    void add(int value);
    Node merge(Node node);
    void output();
}
class Node {
    int value;
    Node next;

    Node(int value) {
        this.value = value;
        this.next = null;
    }
}
class SinglyList implements List {
    Node head;
    int size;

    SinglyList() {
        this.head = null;
        this.size = 0;
    }

    public void add(int value) {
        Node node = new Node(value);
        if (head == null) {
            head = node;
        } else {
            Node currentNode = head;
            while (currentNode.next != null) {
                currentNode = currentNode.next;
            }
            currentNode.next = node;
        }
        size++;
    }

    public Node merge(Node node) {
        Node current1 = this.head;
        Node current2 = node;

        SinglyList newList = new SinglyList();
        while (current1 != null && current2 != null) {
            if (current1.value < current2.value) {
                newList.add(current1.value);
                current1 = current1.next;
            } else {
                newList.add(current2.value);
                current2 = current2.next;
            }
        }

        while (current1 != null) {
            newList.add(current1.value);
            current1 = current1.next;
        }

        while (current2 != null) {
            newList.add(current2.value);
            current2 = current2.next;
        }
        return newList.head;
    }

    public void output() {
        if (head == null) {
            System.out.println("NULL");
        } else {
            Node currentNode = head;
            while (currentNode != null) {
                System.out.print(currentNode.value + " ");
                currentNode = currentNode.next;
            }
        }
    }
}

public class Y {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String str1 = input.nextLine();
        String str2 = input.nextLine();
        String[] arr1 = str1.split(" ");
        String[] arr2 = str2.split(" ");

        List list1 = new SinglyList();
        SinglyList list2 = new SinglyList();

        for (int i = 0; i < arr1.length; i++) {
            if (Integer.parseInt(arr1[i]) == -1) {
                break;
            }
            list1.add(Integer.parseInt(arr1[i]));
        }

        for (int i = 0; i < arr2.length; i++) {
            if (Integer.parseInt(arr2[i]) == -1) {
                break;
            }
            list2.add(Integer.parseInt(arr2[i]));
        }

        Node result = list1.merge(list2.head);

        SinglyList list = new SinglyList();
        list.head = result;
        list.output();
    }
}